﻿using System;
using NaviCar.DB.DataAnnotation;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Linq;

namespace NaviCar.Metadata
{
    public class MetaDados
    {
        public static T RecuperarAtributos<T>(ViewDataDictionary viewData)
             where T: class
        {
            CustomModelMetada metaData = (CustomModelMetada) viewData.ModelMetadata;

            T retorno = null;

            if ((metaData != null))
            {
                retorno = metaData.Attributes.OfType<T>().SingleOrDefault();
            }
            else
            {
                retorno = null;

            }

            return retorno;

        }
    }
}